pro slugparse_event, ev
common slugparse, status
widget_control, ev.id, get_uvalue=uvalue
case uvalue of
'slowno':status.slow=-1
'slowyes':status.slow=1
'hereno':status.here=-1
'hereyes':status.here=1
'name':status.name=ev.value
'go':begin
	if keyword_set(status.name) EQ 0 OR strmatch(status.name, '*.txt') $
				then begin
		lin=''
		if keyword_set(status.name) EQ 0 then $
	 		listfile='slug_parse_list.txt' else $
			listfile=status.name
	   openr, lun,listfile, /get_lun
	     while ~EOF(lun) do begin
		readf, lun, lin
		if keyword_set(lin) then begin
		   lin=strcompress(lin, /remove_all)
		   read_slug, lin, slow=status.slow GT 0,$
	                here=status.here GT 0
		endif
	     endwhile
	   close, lun
	   free_lun, lun
  	end else $
	read_slug, status.name, slow=status.slow GT 0,$
		here=status.here GT 0
     end
else:
endcase

if strmatch(uvalue, 'quit') OR strmatch(uvalue, 'go') then begin
  widget_control, ev.top, /destroy
endif
end


pro slug_parse
common slugparse, status
status={tlb:0L, cancel:0L, go:0L, name:'', slow:-1,$
	here:-1}

status.tlb=widget_base(title='SLUG Parse', /column, xsize=300,$
	ysize=200)
centertlb, status.tlb
dum=cw_field(status.tlb, title='Model Name:', uvalue='name',$
	/all_events)

rowslow=widget_base(status.tlb, /row)
dum=widget_label(rowslow, Value='Parse Slowly?')
rowslow2=widget_base(rowslow, /row, /exclusive)
dum=widget_button(rowslow2, Value='No', uvalue='slowno')
widget_control, dum, /set_button
dum=widget_button(rowslow2, Value='Yes', uvalue='slowyes')

rowslow=widget_base(status.tlb, /row)
dum=widget_label(rowslow, Value='Parse Here?')
rowslow2=widget_base(rowslow, /row, /exclusive)
dum=widget_button(rowslow2, Value='No', uvalue='hereno')
widget_control, dum, /set_button
dum=widget_button(rowslow2, Value='Yes', uvalue='hereyes')



rowbot=widget_base(status.tlb, /row, /align_center)
status.cancel=widget_button(rowbot, uvalue='quit', Value='Cancel')
status.go=widget_button(rowbot, uvalue='go', Value='Parse')

widget_control, status.tlb, /realize
xmanager, 'slugparse', status.tlb

;read_slug, res[0], /here

end
